<script setup lang="ts">
import { useRouter } from 'vue-router'
import { ref } from 'vue'

const router = useRouter()

// 应用列表
interface Application {
  id: string
  title: string
  description: string
  icon: string
  path: string
  color: string
}

const applications = ref<Application[]>([
  {
    id: 'kids-coding',
    title: 'AI少儿编程助手',
    description: '为儿童提供编程学习辅导的AI助手，通过互动式教学帮助孩子学习编程基础',
    icon: '👨‍💻',
    path: '/kids-coding',
    color: '#4f46e5'
  },
  {
    id: 'super-agent',
    title: 'AI超级智能体',
    description: '功能强大的AI智能体，可以回答各种问题，执行复杂任务，提供全面的信息支持',
    icon: '🤖',
    path: '/super-agent',
    color: '#10b981'
  }
])

// 导航到应用页面
const navigateToApp = (path: string) => {
  router.push(path)
}
</script>

<template>
  <div class="home-container">
    <div class="home-view">
      <header class="header">
        <h1>Mahiru AI 智能体平台</h1>
        <p class="subtitle">选择下方应用开始使用</p>
      </header>
      
      <div class="app-grid">
        <div 
          v-for="app in applications" 
          :key="app.id"
          class="app-card"
          :style="{ '--app-color': app.color }"
          @click="navigateToApp(app.path)"
        >
          <div class="app-icon">{{ app.icon }}</div>
          <h2>{{ app.title }}</h2>
          <p>{{ app.description }}</p>
          <button class="app-button">立即使用</button>
        </div>
      </div>
      
      <footer class="footer">
        <p>© {{ new Date().getFullYear() }} Mahiru AI - 智能对话平台</p>
      </footer>
    </div>
  </div>
</template>

<style scoped>
.home-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  background-color: #1e1e1e;
}

.home-view {
  min-height: 100%;
  padding: 40px 20px;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  color: #f0f0f0;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.header h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #4f46e5, #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 1.2rem;
  color: #a0a0a0;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
  flex: 1;
}

.app-card {
  --app-color: #4f46e5;
  background-color: #2d2d2d;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-bottom: 4px solid var(--app-color);
  animation: slideUp 0.6s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

.app-card:nth-child(1) {
  animation-delay: 0.1s;
}

.app-card:nth-child(2) {
  animation-delay: 0.3s;
}

@keyframes slideUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.app-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  background-color: rgba(var(--app-color-rgb, 79, 70, 229), 0.1);
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.app-card h2 {
  font-size: 1.5rem;
  color: var(--app-color);
  margin-bottom: 15px;
}

.app-card p {
  color: #a0a0a0;
  margin-bottom: 25px;
  line-height: 1.5;
}

.app-button {
  background-color: var(--app-color);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 12px 30px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: auto;
  box-shadow: 0 4px 10px rgba(var(--app-color-rgb, 79, 70, 229), 0.3);
}

.app-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(var(--app-color-rgb, 79, 70, 229), 0.4);
}

.footer {
  margin-top: auto;
  text-align: center;
  padding: 20px 0;
  color: #a0a0a0;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .home-container {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .home-view {
    padding: 30px 15px;
    min-height: 100vh;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .app-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .app-card {
    padding: 25px;
  }
  
  .app-icon {
    font-size: 3rem;
    width: 70px;
    height: 70px;
  }
}

@media (max-width: 480px) {
  .home-view {
    padding: 20px 10px;
  }
  
  .header h1 {
    font-size: 1.8rem;
  }
  
  .subtitle {
    font-size: 1rem;
  }
  
  .app-card {
    padding: 20px;
  }
  
  .app-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    margin-bottom: 15px;
  }
  
  .app-card h2 {
    font-size: 1.3rem;
  }
}
</style>
